/*-------------------------------------------------------------------------
 - Copyright (c) 2024-2025 [XD-AMCC TEAM]
 - [XD-AMCC] is licensed under Mulan PSL v2.
 - You can use this software according to the terms and conditions of the Mulan PSL v2.
 - You may obtain a copy of Mulan PSL v2 at:
 -          http://license.coscl.org.cn/MulanPSL2
 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES
 - OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
 - TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 - See the Mulan PSL v2 for more details.
 ------------------------------------------------------------------------*/


/**
 * @brief  Recursive-Descent-Function of non-terminal equalityExpression.
 *
 * @author  WXQ#XDU
 * @date    2024.12
 */

#include "../_parser_inner.h"

#define THIS_NT_ID  equalityExpression

// equalityExpression          //------------------ LL(1) production 78
//    :  relationalExpression
//       (
//          ('=='|'!=')  relationalExpression
//       )*
//
t_tree_ptr RDF_equalityExpression (t_parser_ptr pThis) {
    int productionId = PRD_ID_UNKNOWN;
    t_tree_ptr root = tree_new_parent(THIS_NT, productionId);
    enter_nonterminal ( pThis, THIS_NT, root );
    CHECK_NULLTREE_ABORT ( root, root );
// -------  BEGIN of local action

    productionId = 78;

    t_tree_ptr subTree = RDF_relationalExpression(pThis);
    CHECK_NULLTREE_ABORT (subTree, root);
    tree_add_child(root, subTree);

    //  ( ('=='| '!=') relationalExpression )*
    for (EnumTokenKind la1 = LOOK_AHEAD(pThis) ;
         TK_OP_EQ == la1 || TK_OP_NE == la1    ;
         la1 = LOOK_AHEAD(pThis) )
    {
        subTree = parser_match(pThis, la1);       // consume '==', '!='
        CHECK_NULLTREE_ABORT (subTree, root);
        tree_add_child(root, subTree);

        subTree = RDF_relationalExpression(pThis);
        CHECK_NULLTREE_ABORT (subTree, root);
        tree_add_child(root, subTree);
    }

// -------  END of local action
    if (PRD_ID_UNKNOWN == productionId) {
        ERROR_REPORT_BUG("Forgot to correct the value of "
                         "productionId in RDF_" NT_TEXT "()");
    }
    tree_reset_production( root, productionId );

LABEL_EXIT_RDF:
    exit_nonterminal  ( pThis, THIS_NT, root );
    return root;
}

